import util from '../../../utils/util'
import { ServiceDetail } from '../../../config/api'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    id:'',
    detail:'',
    Imgs:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    let id = options.id;
    console.log('555id',id)
    this.setData({
      id:id
    })
    this.getDetail()
  },

  getDetail(){
    let that = this;
    util.apiRequest(ServiceDetail, {id:that.data.id},null).then( r => {
      console.log('服务详情',r)
      that.setData({
        detail:r.data.data,
        Imgs: r.data.data.attach
      })
    })
  },

  // 预览图片
  previewImg: function (e) {
    let that = this;
    var index = e.currentTarget.dataset.index;
    console.log('预览index', index);
    let imgs = that.data.Imgs;
    console.log('imgs', that.data.Imgs);
    wx.previewImage({
      //当前显示图片
      current: imgs[index],
      //所有图片
      urls: imgs
    })
  },


  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})